import { recipellistReq, recipelinfobyidReq } from '@/api/pharmacy/pharmacy.api';
import { loginReq } from '@/api/user/login'
import QS from 'qs'
export default {
    //刘家豪私有
    namespaced: true,
    state: {
        name: '刘家豪',
        doctorList: [],
        recipelinfo: [],
        usersInfo: {}
    },
    //修改数据
    mutations: {
        M_changeDocList(state: any, payload: {}) {
            state.doctorList = payload
        },
        M_recipelinfo(state: any, payload: any) {
            state.recipelinfo = Object.keys(QS.parse(payload.recipel))
        },
        M_usersInfo(state: any, payload: {}) {
            state.usersInfo = payload
        }
    },
    //做异步处理的
    actions: {
        async A_login({ commit }, payload) {
            // payload 就是角色
            const res = await loginReq(payload)
            commit('M_usersInfo', res.data)
            return res
        },
        async A_doctorList({ commit }, payload) {
            const res = await recipellistReq(payload)
            commit('M_changeDocList', res.data.data)
        },
        async A_prescriptionInfo({ commit }, payload) {
            const res = await recipelinfobyidReq(payload)
            commit('M_recipelinfo', res.data.data[0])
        }
    },
    //store的计算属性
    getters: {},
}

